#include "communication.h"
namespace vehicle {
namespace map {
void RunLcmSubscriber()
{
    lcm::LCM lcm("udpm://239.255.76.67:7667?ttl=1");
    if(!lcm.good())
        return;
        DataHub data_hub;
        lcm.subscribe("VEHICLE_STATUS", &DataHub::OnVehicleStatus, &data_hub);
        lcm.subscribe("GPS_DATA", &DataHub::OnGPSData, &data_hub);
        while (0 == lcm.handle()) {
        }
}


void RunLcmPublisher()
{
    lcm::LCM lcm("udpm://239.255.76.67:7667?ttl=1");
    if(!lcm.good())
        return;

    while (1) {
        lcmtypes::map_info_t map_info = DataProviderMapInfo::Instance()->MapInfo();
        if(lcm.good()){
           lcm.publish("MAP_INFO", &map_info);
        }
        usleep(20000);
    }
}

}
}
